home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / rexx / 1999 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. Path: inforamp.net!usenet
  2. From: daji@inforamp.net
  3. Newsgroups: comp.lang.rexx
  4. Subject: Re: How do I read from a file?
  5. Date: 16 Apr 1996 01:11:54 GMT
  6. Organization: InfoRamp Inc., Toronto, Ontario (416) 363-9100
  7. Distribution: inet
  8. Message-ID: <4kus4q$dvh@sam.inforamp.net>
  9. References: <4ktd9n$3qe@zipper.zip.com.au>
  10. Reply-To: daji@inforamp.net
  11. NNTP-Posting-Host: ts18-07.tor.istar.ca
  12. X-Newsreader: IBM NewsReader/2 v1.2.5
  13.  
  14. In <4ktd9n$3qe@zipper.zip.com.au>, craig@zip.com.au (Craig Pardey) writes:
  15. >Hi,
  16. >
  17. >I just need to know how to open, read from and close a file in rexx.  I have looked in the faq 
  18. >and it's ot there.  Is there an easy way to pull a certain line from the file, or even certain 
  19. >elements like there is in awk?
  20. >
  21. >All help is greatly appreciated.
  22. >
  23. >cheers,
  24. >craig.
  25. >
  26. >-- 
  27. >|    /===\/===\                 | "Better get a lawyer, Son"          |
  28. >|    |   OO   |=============888 | "Better get a real good one."       |
  29. >|    \===/\===/                 |   - Cruel Sea                       |
  30.  
  31. Have you tried to use Rexx built-in functions like LineIn() LineOut()
  32. CharIn() and CharOut(); whcih are used to perform file I/O.
  33.  
  34. To read/write to a file:
  35.  
  36.  
  37. MyFile  = "C:\CONFIG.SYS"
  38. NewFile = "C:\CONFIG.BKP"
  39.  
  40. Do While Lines(MyFile)            /* Continue reading until the end-of-file */
  41.    InLine = LineIn(Myfile)         /* Reads from a file variable myfile      */
  42.    Say InLine                      /* Display line read on the screen        */
  43.    OutLine = LineOut(NewFile)    /* Writes to a file variable NeWfile      */
  44. End
  45.  
  46. Hope this will help.
  47.  
  48. Hasmukh Daji
  49.